export function getLastEightMonths(): string[] {
  const months: string[] = [];
  const monthNames: string[] = [
    'Jan',
    'Feb',
    'Mar',
    'Apr',
    'May',
    'Jun',
    'Jul',
    'Aug',
    'Sep',
    'Oct',
    'Nov',
    'Dec',
  ];

  // 获取当前时间
  const currentDate = new Date();

  // 获取最近8个月
  // eslint-disable-next-line no-plusplus
  for (let i = 7; i >= 0; i--) {
    const date = new Date(currentDate);
    date.setMonth(currentDate.getMonth() - i); // 设置月份，获取过去的月份
    months.push(monthNames[date.getMonth()]); // 将月份名称添加到数组
  }

  return months;
}

export function getCurrentYear(): number {
  const currentDate = new Date();
  return currentDate.getFullYear(); // 获取当前年份
}

export function getCurrentMonth(): string {
  const currentDate = new Date();
  const currentYear = currentDate.getFullYear();
  const currentMonth = String(currentDate.getMonth() + 1).padStart(2, '0');
  return `${currentYear}-${currentMonth}`;
}
